<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS 文字覆盖图像悬停效果 – 从下至上</title>
</head>
<body>
<h2>淡入效果 - 从下至上</h2>
<p>鼠标移动到图片上查看效果</p>

<div class="container">
    <img src="../img/pineapple.jpg" alt="Avatar" class="image">
    <div class="overlay">
        <div class="text">Hello World</div>
    </div>
</div>
<style>
   .image{
       display: block;
   }
    .overlay{
        width: 100%;
        height: 0;
        background-color: blue;
        transition: 1s;
        opacity: 0;
        position: absolute;
        top:100%;
        left:0;
    }
    .text{
        color:white;
       margin: auto;
        position: absolute;
        top:50%;
        left: 50%;
        transform: translate(-50%,-50%);

    }
    .container:hover .overlay{
        opacity: 1;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;


    }
    .container{
        position: relative;
        width: 300px;
        height: 300px;

    }

</style>
</body>
</html>
